package com.rmfyzxfw.caseprocess.controller;

import com.rmfyzxfw.caseprocess.enums.CaseTypeEnum;
import com.rmfyzxfw.caseprocess.enums.DataSourceTypeEnum;
import com.rmfyzxfw.caseprocess.model.po.Status;
import com.rmfyzxfw.caseprocess.model.vo.CourtVO;
import com.rmfyzxfw.caseprocess.model.vo.DictVO;
import com.rmfyzxfw.caseprocess.service.FymcService;
import com.rmfyzxfw.caseprocess.service.StatusService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;

/**
 * @description:
 * @Author: GYW  742926306@qq.com
 * @Date: 2024/8/29 10:12
 */
@RestController
@RequestMapping("api/v3/dict")
@RequiredArgsConstructor
@Api(tags = "字典")
public class DictController {

    private final StatusService statusService;
    private final FymcService fymcService;

    @GetMapping("/caseTypeList")
    @ApiOperation("获取案件类型列表")
    public List<DictVO> caseType(){
        return Arrays.stream(CaseTypeEnum.values())
                .map(c -> new DictVO(c.getName(), c.getType()))
                .collect(Collectors.toList());
    }

    @GetMapping("/dataSourceTypeList")
    @ApiOperation("获取数据源类型列表")
    public List<DictVO> dataSourceTypeList(){
        return Arrays.stream(DataSourceTypeEnum.values())
                .map(c -> new DictVO(c.getName(), c.getType()))
                .collect(Collectors.toList());
    }

    @GetMapping("/allStatus")
    @ApiOperation("获取所有状态")
    public List<Status> allStatus(){
        return statusService.list();
    }

    @GetMapping("/allCourts")
    @ApiOperation("获取法院")
    public List<CourtVO> allCourts(){
        return fymcService.allCourts();
    }
}